<template>
	<view class="make">
		<!-- 头部 -->
		<view class="make_title flex-column-center flex-start">
			<view class="font-323232 font16 font-b">{{dataobj.name}}</view>
			<text class="font-ef9140 font15 font-b">￥{{dataobj.price}}</text>
		</view>
		<!-- 就诊人 -->
		<view class="make_family">
			<view class="family_choois flex-row-start">
				<view class="font-323232 font15 font-b">请选择体检人</view>
				<text class="font-989898 font14">({{getobj.name?getobj.name:'暂无'}})</text>
			</view>
			<view class="family_list">
				<view class="family_name font14 flex-row-center"
					:class="item.id==getobj.physical_user_id?'name_a':'name_b'" v-for="(item,index) in listlUser"
					:key="index" @click="Onchooisfamily(item)">
					{{item.namea}}
				</view>
				<view class="family_add flex-row-center font-6bcbb6" @click="Onaddpeo">+</view>
			</view>
		</view>
		<!-- 边框 -->
		<view class="com_border"></view>
		<!-- 选择日期 -->
		<view class="make_date flex-row-between" @click="OpenDate">
			<view class="font-323232 font14">体检日期</view>
			<view class="font-989898 font14 flex-row-start">
				<view>{{date==''?'请选择':date}}</view>
				<image src="../../../static/my/morea.png" mode=""></image>
			</view>
		</view>
		<!-- 选择体检时间 -->
		<view class="add_but font-ffffff font16 flex-row-center" @click="OnTime">选择体检时间</view>
		<!-- 日期选择 -->
		<ComDate ref="ComDate" @OnDate="OnDate"></ComDate>
	</view>
</template>

<script>
	import ComDate from '@/components/ComDate.vue'
	export default {
		components: {
			ComDate
		},
		data() {
			return {
				id: null,
				dataobj: {},
				getobj: {
					physical_user_id: null,
					name: '',
				},
				listlUser: [], //体检人列表
				date: '', //选择的时间
			}
		},
		onLoad: function(options) {
			this.id = options.id
			//获取详情
			this.OnInfo()
			//获取体检人列表
			this.OnlistlUser()
		},
		methods: {
			//获取详情
			OnInfo() {
				this.$Http({
					url: 'physicalDetails',
					data: {
						physical_id: this.id
					}
				}).then(res => {
					if (res.code == 1) {
						this.dataobj = res.data
					}
				})
			},
			//获取体检人列表
			OnlistlUser() {
				this.$Http({
					url: 'listPhysicalUser',
					data: {}
				}).then(res => {
					if (res.code == 1) {
						if (!res.data || res.data.length == 0) {
							this.getobj.physical_user_id = null
						} else {
							res.data.forEach(item => {
								item.namea = item.name.substring(item.name.length - 2)
							})
							this.getobj.physical_user_id = res.data[0].id
							this.getobj.name = res.data[0].name
						}
						this.listlUser = res.data
					}
				})
			},
			//打开时间弹窗
			OpenDate() {
				this.$refs.ComDate.Onopen()
			},
			//选择时间
			OnDate(e) {
				this.date = e
			},
			//选择就诊人
			Onchooisfamily() {},
			//添加就诊人
			Onaddpeo() {
				uni.navigateTo({
					url: '/pagesA/check/addpeo/addpeo?id=' + this.id,
				})
			},
			//选择时间
			OnTime() {
				if (this.getobj.physical_user_id == null) {
					uni.showToast({
						icon: 'none',
						duration: 3000,
						title: '请先选择体检人'
					});
					return
				}
				if (this.date == '') {
					uni.showToast({
						icon: 'none',
						duration: 3000,
						title: '请选择时间'
					});
					return
				}
				uni.navigateTo({
					url: '/pagesA/check/time/time?id=' + this.id + '&Uid=' + this.getobj.physical_user_id +
						'&time=' + this.date,
				})
			}
		}
	}
</script>

<style lang="less">
	@import url("make.less");
</style>
